/**
 * Created by renzhiqiang on 17/8/12.
 */
import React, { Component } from 'react'
import { connect,Provider} from 'react-redux'
import * as Action from './action';
import { createStore,bindActionCreators } from 'redux'




class Counter extends Component {
   render() {
      const { value, onIncreaseClick, dispatch } = this.props
        function aaa() {
            dispatch({type: 'increase'})
        }
      return (
          <div>
             <span>{value}</span>
             <button onClick={aaa}>Increase</button>
          </div>
      )
   }
}



// Action
function increaseAction(){
    return {
        type: 'increase'
    }
}



// Map Redux state to component props
function mapStateToProps(state) {
   return {
      value: state.count
   }
}

// Map Redux actions to component props
function mapDispatchToProps(dispatch) {
   return {
      onIncreaseClick: bindActionCreators(increaseAction, dispatch)
   }
}

// Connected Component
export default connect(
    mapStateToProps,
    // mapDispatchToProps
)(Counter)